Remove bad interactions of duped waypoints when those waypoints appear
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 19 Jan 2004 18:11:47 +0000 (18:11 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 19 Jan 2004 18:11:47 +0000 (18:11 +0000)
on a queue.

gpsbabel/mapsource.c
gpsbabel/waypt.c

index d898f6c5dc1904efac9adc3a8f37d920683b407a..0dcbcf102559e5b562b6081cfd9dfc2c1cc046d8 100644 (file)
@@ -125,7 +125,6 @@ void
 mps_wpt_q_add(const queue *whichQueue, const waypoint *wpt)
 {
        waypoint *written_wpt = waypt_dupe(wpt);
-       written_wpt->Q.next = written_wpt->Q.prev = NULL;
        ENQUEUE_TAIL(whichQueue, &written_wpt->Q);
 }
 
@@ -809,7 +808,6 @@ mps_waypoint_w_uniqloc_wrapper(waypoint *wpt)
                        /* Not the same lat lon, so rename and add */
                        newName = mkshort(written_wpt_mkshort_handle, wpt->shortname);
                        wptfound = waypt_dupe(wpt);
-                       wptfound->Q.next = wptfound->Q.prev = NULL;
                        xfree(wptfound->shortname);
                        wptfound->shortname = newName;
                        mps_waypoint_w(mps_file_out, mps_ver_out, wptfound, (1==0));
@@ -955,14 +953,12 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
 
                if (tempWpt != NULL) {
                        thisWaypoint = waypt_dupe(tempWpt);
-                       thisWaypoint->Q.next = thisWaypoint->Q.prev = NULL;
                }
                else {
                        tempWpt = mps_find_wpt_q_by_name(&read_route_wpt_head, wptname);
 
                        if (tempWpt != NULL) {
                                thisWaypoint = waypt_dupe(tempWpt);
-                               thisWaypoint->Q.next = thisWaypoint->Q.prev = NULL;
                        }
                        else {
                                /* should never reach here, but we do need a fallback position */
@@ -1061,7 +1057,6 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte)
 
        if (tempWpt != NULL) {
                thisWaypoint = waypt_dupe(tempWpt);
-               thisWaypoint->Q.next = thisWaypoint->Q.prev = NULL;
        }
        else {
                thisWaypoint = waypt_new();
index a62a44d8a5a225b320e2f524f0a10bf9b9754819..32710c729c19d8ac2fd8a57367956d237087fded 100644 (file)
@@ -50,6 +50,12 @@ waypt_dupe(const waypoint *wpt)
                tmp->url = xstrdup(wpt->url);
        if (wpt->url_link_text)
                tmp->url_link_text = xstrdup(wpt->url_link_text);
+       /*
+        * It's important that this duplicated waypoint not appear
+        * on the master Q.
+        */
+       tmp->Q.next = tmp->Q.prev = NULL;
+       tmp->gpx_extras = NULL;
 
        return tmp;
 }